package com.china08.yxyapi.repository.db.statistics;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import com.china08.yxyapi.entity.db.huodong.YxyHuodongLectureSchoolStatistics;

public interface YxyHuodongLectureSchoolStatisticsRepository
        extends JpaRepository<YxyHuodongLectureSchoolStatistics, String> {

    @Transactional(readOnly = true)
    @Query(value = "SELECT SUM(pack_count) FROM yxy_huodong.yxy_huodong_lecture_school_statistics", nativeQuery = true)
    Integer countAll();

    List<YxyHuodongLectureSchoolStatistics> findTop19ByAreaIdDistrictOrderByPackCountDesc(String code);

    List<YxyHuodongLectureSchoolStatistics> findTop10ByAreaIdDistrictOrderByPackCountDesc(String code);

    List<YxyHuodongLectureSchoolStatistics> findByAreaIdDistrictOrderByPackCountDesc(String code);

    YxyHuodongLectureSchoolStatistics findBySchoolId(String sid);

    Integer countByAreaIdDistrict(String code);

}
